<!-- 选择产品图 -->
<template>
	<uni-popup ref="pickerView" type="bottom" :zIndex="999" background-color="transparent" :safeArea="false">
		<view class="popup-view">
			<view class="header">
				<view class="title flex">
					<view class="">选择{{ type === 1 ? "空间" : "产品" }}示例图</view>
					<view class="close">
						<image :src="$imgsUrl('0x725070112')" mode=""></image>
					</view>
				</view>
			</view>

			<view :class="['list', type === 2 ? 'list_product' : '']">
				<view :class="['item']" v-for="item in currentList" :key="item.id" @tap="clickItem">
					<view class="cover">
						<image :src="item.cover" mode="aspectFill"></image>
						<view class="view_icon" @tap.stop="viewImg(item.cover)">
							<image :src="$imgsUrl('0x725070111')" mode=""></image>
						</view>
					</view>
					<view class="info">
						<view class="u-line-1">
							{{ item.name }}
						</view>
					</view>
				</view>
			</view>
		</view>
	</uni-popup>
</template>

<script>
export default {
	name: "selectProductImg",
	props: {
		// 1空间示例图 2产品示例图
		type: {
			type: Number,
			default: 2
		}
	},
	data() {
		return {
			selectIds: ["11"],
			productList: [
				{
					id: "1",
					name: "沙发",
					cover: this.$imgsUrl("0x725070126")
				},
				{
					id: "2",
					name: "复合地板",
					cover: this.$imgsUrl("0x725070121")
				},
				{
					id: "3",
					name: "涂料",
					cover: this.$imgsUrl("0x725070122")
				},
				{
					id: "4",
					name: "瓷砖",
					cover: this.$imgsUrl("0x725070123")
				},
				{
					id: "5",
					name: "门板",
					cover: this.$imgsUrl("0x725070124")
				},
				{
					id: "6",
					name: "台面",
					cover: this.$imgsUrl("0x725070125")
				}
			],
			spaceList: [
				{
					id: "1",
					name: "毛坯房",
					cover: this.$imgsUrl("0x725070120")
				},
				{
					id: "2",
					name: "精装房",
					cover: this.$imgsUrl("0x725070113")
				},
				{
					id: "3",
					name: "旧房",
					cover: this.$imgsUrl("0x725070114")
				},
				{
					id: "4",
					name: "客厅实景",
					cover: this.$imgsUrl("0x725070115")
				},
				{
					id: "5",
					name: "客厅实景",
					cover: this.$imgsUrl("0x725070116")
				},
				{
					id: "6",
					name: "卧室实景",
					cover: this.$imgsUrl("0x725070117")
				},
				{
					id: "8",
					name: "厨房实景",
					cover: this.$imgsUrl("0x725070118")
				},
				{
					id: "9",
					name: "厨房实景",
					cover: this.$imgsUrl("0x725070119")
				}
			]
		};
	},
	computed: {
		currentList() {
			return this.type === 1 ? this.spaceList : this.productList;
		}
	},
	mounted() {},
	methods: {
		clickItem(url) {
			this.$emit("confirm", { url, type: this.type });
		},
		viewImg(url) {
			uni.previewImage({
				urls: [url]
			});
		},
		close() {
			this.$refs.pickerView.close();
		},
		open() {
			this.$refs.pickerView.open();
		},
		submit() {
			this.close();
		},
		change() {
			this.close();
		}
	}
};
</script>

<style lang="less" scoped>
.popup-view {
	width: 100%;
	min-height: 500rpx;
	background: #fff;
	border-radius: 24rpx 24rpx 0 0;
	padding: 0 0 calc(56rpx + env(safe-area-inset-bottom) / 2) 0;
	// border-radius: 24rpx 24rpx 0 0;
	// background: linear-gradient( 180deg, rgba(72,108,246,0.1) 0%, rgba(72,108,246,0) 100%);
}

.list.list_product {
	.item {
		.cover {
			height: 208rpx;
		}
	}
}

.list {
	padding: 30rpx 30rpx 0 30rpx;
	display: flex;
	flex-wrap: wrap;
	--margin-item: calc((100% - 624rpx) / 2);
	:nth-child(3n).item {
		margin-right: 0;
	}
}
.item {
	width: 208rpx;
	border-radius: 16rpx;
	border: 1px solid transparent;
	color: #333333;
	font-size: 28rpx;
	text-align: center;
	margin-right: var(--margin-item);
	margin-bottom: 30rpx;

	.info {
		height: 100rpx;
		padding: 16rpx 16rpx 0 16rpx;
		background-color: #fff;
	}
	.cover {
		width: 100%;
		height: 156rpx;
		border-radius: 16rpx;
		position: relative;
		overflow: hidden;
		.view_icon {
			padding: 8rpx;
			position: absolute;
			right: 0;
			bottom: 0;
			z-index: 3;
			image {
				width: 38rpx;
				height: 38rpx;
			}
		}
	}
}

.header {
	// box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.05);
	border-bottom: 1px solid #f5f5f5;
	.title {
		position: relative;
		padding: 38rpx 34rpx 46rpx 34rpx;
		font-size: #333333;
		font-weight: bold;
		font-size: 34rpx;
		.close {
			position: absolute;
			right: 30rpx;
			padding: 8rpx;
			image {
				width: 46rpx;
				height: 46rpx;
			}
		}
	}
}
</style>
